package com.eksframework.commons.core.validator;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * 自动配置
 *
 * @author chenfenghai
 * @version: 1.0
 * @date: 2020-12-03 10:36
 */
@Configuration
public class ValidatorConfigurationAuto {

    /**
     * 默认Json配置
     *
     * @return ObjectMapper
     */
    @Bean
    @ConditionalOnMissingBean(Validator.class)
    public Validator validator() {
        return Validation.buildDefaultValidatorFactory().getValidator();
    }
}
